#include<stdio.h>
#include<stdlib.h>
int main()
{
	int num, i, j = 0, k = 0, l = 0, m = 0, n = 0, o = 0;
	double	score[30];
	char name[8][30];
	double ave(double score[], int num);
	double a;

	printf("请输入人数(不多于30人)num:");
	scanf("%d", &num);

	for (i = 0; i<num; i++)
	{
		printf("请输入第%d个学生的姓名:", i + 1);
		scanf("%s", name[i]);
		printf("请输入第%d个学生的成绩:", i + 1);
		scanf("%lf", &score[i]);
	}

	printf("不及格学生为:");
	for (i = 0; i<num; i++)
	{
		if (score[i] < 60)
		{
			printf("%s", name[i]);
			j++;
		}
	}
	printf("\n不及格学生人数为:%d", j);

	a = ave(score, num);
	printf("\n平均分为:ave=%lf\n", a);

	printf("分数在平均分以下的学生为:");
	for (i = 0; i<num; i++)
	{
		if (score[i] <  a)
		{
			printf("%s", name[i]);
			k++;
		}
	}
	printf("\n分数在平均分以下的学生人数为:%d\n", k);

	for (i = 0; i<num; i++)
	{
		if (score[i] >= 90){ o++; }
		if (score[i]<90 && score[i] >= 80){ n++; }
		if (score[i]<80 && score[i] >= 70){ m++; }
		if (score[i]<70 && score[i] >= 60){ l++; }
	}
	printf("分数段         学生人数               图形\n");
	printf("<60            %d(%lf%%)          ", j, (double)j / num * 100);
	for (i = 0; i<j; i++)printf("*");
	printf("\n60-69          %d(%lf%%)          ", l, (double)l / num * 100);
	for (i = 0; i<l; i++)printf("*");
	printf("\n70-79          %d(%lf%%)          ", m, (double)m / num * 100);
	for (i = 0; i<m; i++)printf("*");
	printf("\n80-89          %d(%lf%%)          ", n, (double)n / num * 100);
	for (i = 0; i<n; i++)printf("*");
	printf("\n>=90           %d(%lf%%)          ", o, (double)o / num * 100);
	for (i = 0; i<o; i++)printf("*");
	printf("\n");
}

double ave(double score[], int num)
{
	int i, sum = 0, ave;
	for (i = 0; i<num; i++)
	{
		sum += score[i];
	}
	ave = sum / num;
	return ave;
}